﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MISAPP.Classify.DataAccess;
using System.Data;
using MISAPP.MISInterface;

namespace MISAPP.Classify.Service
{
    public class Service_CIB006
    {
        protected DA_CIB006 da = null;
        protected DA_CIB006 DA
        {
            get
            {
                if (da == null)
                {
                    da = new DA_CIB006();
                }
                return da;
            }
        }


        public string[] GetCriteriaArray()
        {
            return DA.GetDistinctField();
        }

        public DataSet GetCriteriaData()
        {
            return DA.GetCriteria();
        }

        public DataTable GetGroupBy()
        {
            return DA.GetGroupBy();
        }

        public DataTable GetSummaryData(System.Collections.ArrayList p_criteria)
        {
            DataTable dt = null;
            try
            {
                DA.ResetCriteria();
                List<iSelectList> criteriaList = p_criteria[0] as List<iSelectList>;
                string fldList = p_criteria[1].ToString();
                string[] yms = null;
                foreach (SelectList SL in criteriaList)
                {
                    //DA.AddCriteria("A." + SL.GetField(), DA.GetInString(SL.GetReverse()), SL.GetListArray());
                    yms = SL.GetListArray();
                }
                dt = DA.GetSummaryData(fldList,yms);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return dt;
        }

        public DataTable GetDetailData(System.Collections.ArrayList p_criteria)
        {
            DataTable dt = null;
            try
            {
                DA.ResetCriteria();
                List<iSelectList> criteriaList = p_criteria[0] as List<iSelectList>;
                Dictionary<string,string> fldList = p_criteria[1] as Dictionary<string,string>;
                string[] yms = null;
                foreach (SelectList SL in criteriaList)
                {
                    yms = SL.GetListArray();
                }
                dt = DA.GetDetailData(fldList, yms);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return dt;
        }

    }
}
